package com.kaiming.processor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

/**
 * ClassName: MyBeanFactoryPostProcessor
 * Package: com.kaiming.processor
 * Description:
 *
 * @Auther gongkaiming
 * @Create 2025/10/24 21:58
 * @Version 1.0
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("MyBeanFactoryPostProcessor的postProcessBeanFactory方法");
        //        System.out.println("beanDefinitionMap填充完成后回调该方法");
//        BeanDefinition beanDefinition = beanFactory.getBeanDefinition("userService");
//        beanDefinition.setBeanClassName("com.kaiming.dao.impl.UserDaoImpl");
        
        // 注册
//        RootBeanDefinition beanDefinition = new RootBeanDefinition();
//        beanDefinition.setBeanClassName("com.kaiming.dao.impl.PersonDaoImpl");
//
//        DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) beanFactory;
//
//        defaultListableBeanFactory.registerBeanDefinition("personDao", beanDefinition);
    }
}
